package com.icim.xmtm5.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import com.icim.xmtm5.entity.CtSlimifShipProduct5;

@Repository
public class CtSlimifshipproduct5Dao {
    @Resource
    private JdbcTemplate xmtm5JdbcTemplate;

    public List<CtSlimifShipProduct5> listSheets(String boxId,String vendorCode) {
        String sql = "SELECT * FROM V_XM_G5_SLIMIFSHIPPRODUCT_HC WHERE BOXNAME = ? AND VENDORCODE = ?";
        return xmtm5JdbcTemplate.query(sql, new Object[] { boxId, vendorCode }, new RowMapper<CtSlimifShipProduct5>() {
            @Override
            public CtSlimifShipProduct5 mapRow(ResultSet rs, int rowNum) throws SQLException {
                CtSlimifShipProduct5 cfSlimifshipbox = new CtSlimifShipProduct5();
                cfSlimifshipbox.setFactoryname(rs.getString("FACTORYNAME"));
                cfSlimifshipbox.setProductrequestname(rs.getString("PRODUCTREQUESTNAME"));
                cfSlimifshipbox.setProductspecname(rs.getString("PRODUCTSPECNAME"));
                cfSlimifshipbox.setBoxname(rs.getString("BOXNAME"));
                cfSlimifshipbox.setLotname(rs.getString("LOTNAME"));
                cfSlimifshipbox.setProductname(rs.getString("PRODUCTNAME"));
                cfSlimifshipbox.setPosition(rs.getInt("POSITION"));
                cfSlimifshipbox.setProductgrade(rs.getString("PRODUCTGRADE"));
                cfSlimifshipbox.setBoxrealid(rs.getString("BOXREALID"));
                return cfSlimifshipbox;
            }

        });
    }

}
